package com.sias.reflection;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * @author 吴文杰
 * @version 1.0
 * @createTime 2023-05-02 17:42:49
 */
@SuppressWarnings("all")
public class HomeWork01 {
  public static void main(String[] args) throws Exception {
    Class<PrivateTest> cls = PrivateTest.class;
    PrivateTest o = cls.newInstance();
    Field name = cls.getDeclaredField("name");
    name.setAccessible(true);
    name.set(o,"吴文杰");

    Method getName = cls.getMethod("getName");
    Object invoke = getName.invoke(o);
    System.out.println(invoke);
  }
}
class PrivateTest{
  private String name = "helloKitty";

  public String getName() {
    return name;
  }

}